package cn.iocoder.yudao.module.lfd.dal.mysql.schedule;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.lfd.controller.admin.appointment.vo.AppointmentForm;
import cn.iocoder.yudao.module.lfd.controller.admin.appointment.vo.AppointmentPageReqVO;
import cn.iocoder.yudao.module.lfd.dal.dataobject.appointment.AppointmentListDO;
import cn.iocoder.yudao.module.lfd.dal.dataobject.schedule.NickScheduleDO;
import cn.iocoder.yudao.module.lfd.dal.dataobject.schedule.ScheduleDO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.lfd.controller.admin.schedule.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 排班 Mapper
 *
 * @author 陈星星
 */
@Mapper
public interface ScheduleMapper extends BaseMapperX<ScheduleDO> {

    Page<NickScheduleDO> list(@Param("page") Page<SchedulePageReqVO> page, @Param("pageReqVO") SchedulePageReqVO pageReqVO);


    default PageResult<ScheduleDO> selectPage(SchedulePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ScheduleDO>()
                .eqIfPresent(ScheduleDO::getShopId, reqVO.getShopId())
                .eqIfPresent(ScheduleDO::getBarberId, reqVO.getBarberId())
                .eqIfPresent(ScheduleDO::getWeek, reqVO.getWeek())
                .eqIfPresent(ScheduleDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ScheduleDO::getStartWork, reqVO.getStartWork())
                .eqIfPresent(ScheduleDO::getEndWork, reqVO.getEndWork())
                .betweenIfPresent(ScheduleDO::getStartOvertime, reqVO.getStartOvertime())
                .betweenIfPresent(ScheduleDO::getEndOvertime, reqVO.getEndOvertime())
                .betweenIfPresent(ScheduleDO::getTotalOvertime, reqVO.getTotalOvertime())
                .eqIfPresent(ScheduleDO::getScheduleDate, reqVO.getScheduleDate())
                .betweenIfPresent(ScheduleDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ScheduleDO::getId));
    }

    default List<ScheduleDO> selectList(ScheduleExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ScheduleDO>()
                .eqIfPresent(ScheduleDO::getShopId, reqVO.getShopId())
                .eqIfPresent(ScheduleDO::getBarberId, reqVO.getBarberId())
                .eqIfPresent(ScheduleDO::getWeek, reqVO.getWeek())
                .eqIfPresent(ScheduleDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ScheduleDO::getStartWork, reqVO.getStartWork())
                .eqIfPresent(ScheduleDO::getEndWork, reqVO.getEndWork())
                .betweenIfPresent(ScheduleDO::getStartOvertime, reqVO.getStartOvertime())
                .betweenIfPresent(ScheduleDO::getEndOvertime, reqVO.getEndOvertime())
                .betweenIfPresent(ScheduleDO::getTotalOvertime, reqVO.getTotalOvertime())
                .eqIfPresent(ScheduleDO::getScheduleDate, reqVO.getScheduleDate())
                .betweenIfPresent(ScheduleDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ScheduleDO::getId));
    }

}
